from django.db import models
from expertos.models import Experto
from genericm2m.models import RelatedObjectsDescriptor

# Create your models here.
class Autor(models.Model):
    nombre = models.CharField(max_length=100)
    apellido = models.CharField(max_length=100)
    institucion = models.CharField(max_length=100,blank=True,null=True)
    experto = models.ForeignKey(Experto,blank=True,null=True)
    orden = models.IntegerField()
    
    def __unicode__(self):
        return u'%s, %s' % (self.apellido,self.nombre)
    
class AutorOrdenado(models.Model):
    nombre = models.CharField(max_length=100)
    apellido = models.CharField(max_length=100)
    institucion = models.CharField(max_length=100,blank=True,null=True)
    orden = models.IntegerField()
    experto = models.ForeignKey(Experto,blank=True,null=True)
    def __unicode__(self):
        return u'%s,%s' % (self.apellido,self.nombre)
    def get_pk(self):
        return str(self.pk)
    
class ExpertoAutorOrdenado(models.Model):
    nombre = models.CharField(max_length=100)
    apellido = models.CharField(max_length=100)
    institucion = models.CharField(max_length=100,blank=True,null=True)
    experto = models.ForeignKey(Experto,blank=True,null=True)
    orden = models.IntegerField()
    
    def __unicode__(self):
        return u'%s' % self.experto
    def get_pk(self):
        return str(self.pk)

  
class AutorTodosOrdenado(models.Model):
    autores_todos = RelatedObjectsDescriptor()
    orden = models.IntegerField()